import React, { Component } from 'react'
import qs from 'querystringify'

export default class Params extends Component {
  constructor() {
    super()
  }
  render() {
    console.log(this.props.location.search);
    // 获取参数方式1：
    let data = new URLSearchParams(this.props.location.search);
    console.log(data.get('age'));
    console.log(data.get('name'));
    // 获取参数方式2： npm i querystringify -s 安装依赖，通过parse方法转换格式
    let data1 = qs.parse(this.props.location.search);
    console.log(data1.age);
    console.log(data1.name);
    return (
      <div>
        <p>路由传参</p>
      </div>
    )
  }
}
